<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/admin/include/init_admin.jsp" %>
<%@ page import="com.welfare.admin.call.*" %>
<%

	HashList code305	= CommonUtil.getCodeList("305");	//분류1
	HashList code306	= CommonUtil.getCodeList("306");	//분류2

	String job_type			= StringUtil.nvl(request.getParameter("job_type"),"U");
	String manual_id		= StringUtil.nvl(request.getParameter("manual_id"));


	HashMap infos = new HashMap();
	infos.put("manual_id",	manual_id);


	CallDAO dao 		= new CallDAO();
	HashList info		= dao.selectManualInfo(infos);		
	
	
	HashList fileList	= CommonUtil.getFileList(StringUtil.nvl(info.get("file_ref_id",0)));

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title><%= SYSTEM_NAME %></title>
	<%@ include file="/admin/include/cssnjs.jsp"  %>
	<script type="text/javascript" src="../../SE2.3.1.O9858/js/HuskyEZCreator.js" charset="utf-8"></script>

	<script type="text/javascript">
	var oEditors = [];
	
	$(document).ready(function() {
		
		cfInitSE("content_info");
		
	});

	
	function fnSave() {
		if (cfCheckRequired(document.saveForm.counsel_kind, '분류1을 선택하세요')
				&& cfCheckRequired(document.saveForm.counsel_part, '분류2을 선택하세요')
				&& cfCheckRequired(document.saveForm.subject, '제목을 입력하세요')
		) {
			if (confirm(MSG_<%= job_type%>)) {
				oEditors.getById["content_info"].exec("UPDATE_CONTENTS_FIELD", []);
				return true;
			}
		}	
		
		return false;
	}

	
	function fnAddFile() {
		$('#fileList').append('<div class="mt4"><input type="file" name="attach_file_path['+$('#fileList div').length+']" value="" class="w400"/></div>');
	}
	
	function fnDeleteFile(oThis) {
		if (confirm(MSG_DELETE)) {
			var fileId = $(oThis).closest('span').attr('id');
			$.ajax({
				url: '/common/fileSave.do',
				type: "POST",
			    dataType: 'json',//html,text,json
			    data: { //파라미터
			    	job_type : 'D',
			    	file_id : fileId
			    },
			    error: function(data, status, err){
			    	alert(err);
			    },
				success: function(data){
					$(oThis).closest('span').hide();
			    }
			});
		}
	}
	

	</script>
</head>
<body>
<div id="wrap">
		<div id="popup">
		
		
			<form name="saveForm" id="saveForm" method="post" action="./manualSave.do" enctype="multipart/form-data" onsubmit="return fnSave()">
			<input type="hidden" name="job_type" id="job_type" value="<%= job_type %>"/>
			<input type="hidden" name="manual_id" value="<%= info.get("manual_id", 0) %>"/>
			<input type="hidden" name="file_ref_id" value="<%= info.get("file_ref_id", 0) %>"/>
			
			<div class="menu_title">
				<h1>내부게시판</h1>
				<div class="r mt2">
			<%	if (isAdmin) { %>
					<input type="image" class="button" src="../images/btn_save.gif" />
					<a href="./manualInfo.jsp?manual_id=<%=manual_id%>"><img src="../images/btn_cancel.gif" /></a>
			<%	} %>
					<a href="#nohref"  onclick="self.close()"><img src="../images/btn_close.gif"/></a>
				</div>
			</div>
			<div class="clear line_01"></div>

			
			<table cellpadding="0" cellspacing="0" class="table_01 mt5">
			<colgroup>
				<col width="80px"/>
				<col/>
				<col width="80px"/>
				<col/>
				<col width="80px"/>
				<col/>
			</colgroup>
			<tbody>
				<tr>
					<th><p>분류1</p></th>
					<td>
						<select name="counsel_kind" class="w120">
						<%= StringUtil.makeOption(code305, info.get("counsel_kind", 0)) %>
						</select>
					</td>
					<th><p>분류2</p></th>
					<td>
						<select name="counsel_part" class="w120">
						<%= StringUtil.makeOption(code306, info.get("counsel_part", 0)) %>
						</select>
					</td>
					<th><p>공지여부</p></th>
					<td>
						<input type="checkbox" name="notice_yn" value="Y" <%= StringUtil.checked(info.get("notice_yn",0),"Y") %>/>
					</td>
				</tr>
				<tr>
					<th><p>제목</p></th>
					<td colspan="5">
						<input type="text" class="text wmax" name="subject" value="<%= info.get("subject", 0) %>" />
					</td>
				</tr>
				<tr>
					<th><p>내용</p></th>
					<td colspan="5">
						<textarea id="content_info" name="content_info"  style="width:99%; height:300px"><%= info.get("content_info", 0) %></textarea>
					</td>
				</tr>
				<tr>
					<th><p>기타사항</p></th>
					<td colspan="5">
						<textarea name="etc_info" rows="4" style="width:99%;"><%= info.get("etc_info", 0) %></textarea>
					</td>
				</tr>
				<tr>
					<th><p>파일첨부</p></th>
					<td colspan="5" id="fileList">
						
			<%		for (int i = 0; i < fileList.size(); i++) { %>
						<span class="file_download" id="<%= fileList.get("file_id",i) %>">
							<img src="../../images/common/<%= StringUtil.getFileExtIcon(fileList.get("file_ext",i)) %>"/><%= fileList.get("file_name",i) %>
							<a href="#nohref" onclick="fnDeleteFile(this)"><img class="ico_remove" src="../images/ico_remove.gif" align="absmiddle" title="파일삭제"/></a><%= i<fileList.size()-1?",":"" %>
						</span>
			<%		} %>
						
						<div>
							<input type="file" name="attach_file_path[0]" value="" class="w400"/>
							<a href="#nohref" onclick="fnAddFile()"><img src="../images/btn_add.gif" align="absmiddle"/></a>
						</div>
						
					</td>
				</tr>
			</tbody>
			</table>
			</form>
			
		</div>
		
</div>



</body>
</html>
